<?php
/**
 * Created by Yevgen Vershynin.
 * User: Yevgen Vershynin
 * Description: Describes Product object. Creation and validation of Product object.
 */
class ProductObject
{
    public $code = "";
    public $name = "";
    public $productLine = "";
    public $scale = "";
    public $vendor = "";
    public $description = "";
    public $quantityInStock = "";
    public $buyPrice = "";
    public $msrp = "";

    public function __construct($dbData)
    {
        //Validate if parameters are set and save them to object values.
        if(isset($dbData['productCode'])) {
            $this->code = $dbData['productCode'];
        }
        if(isset($dbData['productName'])) {
            $this->name = $dbData['productName'];
        }
        if(isset($dbData['productLine'])) {
            $this->productLine = $dbData['productLine'];
        }
        if(isset($dbData['productScale'])) {
            $this->scale = $dbData['productScale'];
        }
        if(isset($dbData['productVendor'])) {
            $this->vendor = $dbData['productVendor'];
        }
        if(isset($dbData['productDescription'])) {
            $this->description = $dbData['productDescription'];
        }
        if(isset($dbData['quantityInStock'])) {
            $this->quantityInStock = $dbData['quantityInStock'];
        }
        if(isset($dbData['buyPrice'])) {
            $this->buyPrice = $dbData['buyPrice'];
        }
        if(isset($dbData['MSRP'])) {
            $this->msrp = $dbData['MSRP'];
        }
    }
}
